import request from '@/config/axios'

export interface PermissionAssignUserRoleReqVO {
  userId: number
  roleIds: number[]
}

export interface PermissionAssignRoleMenuReqVO {
  roleId: number
  menuIds: number[]
}

export interface PermissionAssignRoleDataScopeReqVO {
  roleId: number
  dataScope: number
  dataScopeDeptIds: number[]
}

export interface PermissionAssignRoleSiteScopeReqVO {
  roleId: number
  siteDataScope: number
  dataScopeSiteIds: number[]
}

export interface PermissionAssignRoleChannelScopeReqVO {
  roleId: number
  siteId: number
  channelDataScope: number
  dataScopeChannelIds: number[]
}

export interface PermissionAssignRoleContentScopeReqVO {
  roleId: number
  siteId: number
  docDataScope: number
  dataScopeChannelIds: number[]
}
export interface PermissionAssignUserGroupReqVO {
  userId: number
  groupIds: number[]
}
// 查询角色拥有的菜单权限
export const getRoleMenuList = async (roleId: number) => {
  return await request.get({ url: '/system/permission/list-role-menus?roleId=' + roleId })
}

// 赋予角色菜单权限
export const assignRoleMenu = async (data: PermissionAssignRoleMenuReqVO) => {
  return await request.post({ url: '/system/permission/assign-role-menu', data })
}

// 赋予角色数据权限
export const assignRoleDataScope = async (data: PermissionAssignRoleDataScopeReqVO) => {
  return await request.post({ url: '/system/permission/assign-role-data-scope', data })
}

// 查询用户拥有的角色数组
export const getUserRoleList = async (userId: number) => {
  return await request.get({ url: '/system/permission/list-user-roles?userId=' + userId })
}

// 赋予用户角色
export const assignUserRole = async (data: PermissionAssignUserRoleReqVO) => {
  return await request.post({ url: '/system/permission/assign-user-role', data })
}

// 赋予角色站群权限
export const assignRoleSiteScopeApi = async (data: PermissionAssignRoleSiteScopeReqVO) => {
  return await request.post({ url: '/system/permission/assign-role-site-data-scope', data })
}

// 赋予角色栏目权限
export const assignRoleChannleScopeApi = async (data: PermissionAssignRoleChannelScopeReqVO) => {
  return await request.post({ url: '/system/permission/assign-role-channel-data-scope', data })
}

// 赋予角色内容权限
export const assignRoleContentScopeApi = async (data: PermissionAssignRoleContentScopeReqVO) => {
  return await request.post({ url: '/system/permission/assign-role-content-data-scope', data })
}

// 查询用户拥有的会员组数组
export const getUserGroupList = async (userId: number) => {
  return await request.get({ url: '/system/permission/list-user-groups?userId=' + userId })
}
// 赋予用户会员组
export const assignUserGroup = async (data: PermissionAssignUserGroupReqVO) => {
  return await request.post({ url: '/system/permission/assign-user-group', data })
}
